﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using PowerCreator.LMS.Common.Script;
using PowerCreator.LMS.Web.Task;
using PowerCreator.LMS.Task.Entity;

public partial class sysadmin_TaskManager_AddTaskClassRoom : System.Web.UI.Page
{
    TaskClassRoomManag objTaskClassRoomManag = new TaskClassRoomManag();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
            {
                int TaskCRID = int.Parse(Request.Params["id"].ToString());
                ViewState["TaskCRID"] = TaskCRID;
                ShowInfo(TaskCRID);
            }
        }
    }
    private void ShowInfo(int TaskCRID)
    {

        TaskClassRoom model = objTaskClassRoomManag.Load(TaskCRID);
        
        //this.lblTaskCRID.Text = model.TaskCRID.ToString();
        this.txtTaskCRName.Text = model.TaskCRName;
        this.txtTaskCRIP.Text = model.TaskCRIP;
        //this.txtTaskCrVirId.Text = model.TaskCrVirId.ToString();
        //this.txtTaskCrAuditState.Text = model.TaskCrAuditState.ToString();
        this.txtTaskCRRemark.Text = model.TaskCRRemark;
        //this.txtTaskCRCreateTime.Text = model.TaskCRCreateTime.ToString();
        //this.txtFKTaskCRCreateID.Text = model.FKTaskCRCreateID.ToString();

    }
    protected void btnSave_Click(object sender, EventArgs e)
    {

        string TaskCRName = this.txtTaskCRName.Text;
        string TaskCRIP = this.txtTaskCRIP.Text;
        int TaskCrVirId = 0;
        int TaskCrAuditState = 1;
        string TaskCRRemark = this.txtTaskCRRemark.Text;
        DateTime TaskCRCreateTime = DateTime.Now;
        int FKTaskCRCreateID = 10000;

        TaskClassRoom model = new TaskClassRoom();
        if (ViewState["TaskCRID"] != null)
        {
            model = objTaskClassRoomManag.Load(int.Parse(ViewState["TaskCRID"].ToString()));
        }
        model.TaskCRName = TaskCRName;
        model.TaskCRIP = TaskCRIP;
        model.TaskCrVirId = TaskCrVirId;
        model.TaskCrAuditState = TaskCrAuditState;
        model.TaskCRRemark = TaskCRRemark;
        model.TaskCRCreateTime = TaskCRCreateTime;
        model.FKTaskCRCreateID = FKTaskCRCreateID;
        bool result;
        if (ViewState["TaskCRID"] == null)
        {
            result = objTaskClassRoomManag.AddNew(model);
        }
        else
        {
            result = objTaskClassRoomManag.Update(model);
        }
        if (result)
        {
            Script.RedirectURL("ManagerTaskClassRoom.aspx");
        }
    }
    protected void btnReset_Click(object sender, EventArgs e)
    {
        Script.RedirectURL("ManagerTaskClassRoom.aspx");
    }
}
